import operator
import os
import csv
import time
import threading
import queue
import datetime
import multiprocessing
from time import ctime
import pandas as pd

def read_file(filpos):
    csvfile = open(filpos,'r',encoding="utf-8-sig")
    reader = pd.read_csv(csvfile)
    index = 0
    print(filpos)
    while index < len(reader):
        row_date = reader.iloc[index].values # 返回一个list
        
        index = index + 1

threads = []
#join在里面时候只有第一个子进程结束才能打开第二个进程,if__name__ 调用时不可用
if __name__=="__main__":
    start = datetime.datetime.now()
    q = queue.Queue(10)
    path_date = os.listdir('./date')
    for i in range(len(path_date)):
        STOCKS_FILE = './date/' + path_date[i]
        #p1 = multiprocessing.Process(target=read_file,args=(STOCKS_FILE,))
        t= threading.Thread(target=read_file,args=(STOCKS_FILE,))
        threads.append(t)

    for thr in threads:
        thr.start()
        while True:
            if(len(threading.enumerate()) < 50):
                break
    end = datetime.datetime.now()
    print(end-start)
        

